#pragma GCC optimize(2,3,"Ofast")
#include<bits/stdc++.h>
#define ll long long
#define eb emplace_back
#define ep emplace
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define mems(arr,x) memset(arr,x,sizeof(arr))
#define memc(arr1,arr2) memcpy(arr1,arr2,sizeof(arr2))
using namespace std;
const int maxn=4e5+10;
int q,m;
set<ll> s;
ll v[maxn],a[maxn],b[maxn];
bool f[maxn];
void discrete(){
    for(int i=1;i<=q;i++)   b[i]=a[i];
    sort(b+1,b+q+1);
    m=unique(b+1,b+q+1)-b-1;
    for(int i=1;i<=q;i++)   a[i]=lower_bound(b+1,b+m+1,a[i])-b;
}
void maker(){
    mt19937 matt(time(0));
    auto rndll=[&](){return abs((ll)(matt()));};
    int n=3e4;
    printf("%d\n",n);
    for(int i=1;i<=n;i++)printf("%lld ",rndll()%n+1);
    exit(0);
}
namespace FastIO{
    const int SIZ=1000000;
    static char buf[SIZ+10],*p1=buf,*p2=buf,obuf[SIZ+10],*p3=obuf,cc[40];
    inline void flush(){fwrite(obuf,p3-obuf,1,stdout);}
    inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,SIZ,stdin),p1==p2)?EOF:*p1++;}
    inline void putc(char x){(p3-obuf<SIZ)?(*p3++=x):(fwrite(obuf,p3-obuf,1,stdout),p3=obuf,*p3++=x);}
    inline int read(){
        int x=0; int f=1; char c=getc();
        while(c<48||c>57){if(c=='-')f=-1;c=getc();}
        while(c>=48&&c<=57)x=(x<<3)+(x<<1)+(c^48),c=getc();
        x*=f;
        return x;
    }
    inline ll readll(){
        ll x=0; int f=1; char c=getc();
        while(c<48||c>57){if(c=='-')f=-1;c=getc();}
        while(c>=48&&c<=57)x=(x<<3)+(x<<1)+(c^48),c=getc();
        x*=f;
        return x;
    }
    inline void print(auto x){ 
        if(!x)return putc(48),void();
        int len=0;
        if(x<0)x=-x,putc(45);
        while(x)cc[len++]=x%10+48,x/=10;
        while(len--)putc(cc[len]);
    }
    inline void prints(string s){for(char c:s)putc(c);}
}
using FastIO::read;
using FastIO::readll;
using FastIO::print;
using FastIO::prints;
using FastIO::getc;
using FastIO::putc;
using FastIO::flush;
int main(){
    freopen("kte.in","r",stdin);freopen("kte.out","w",stdout);
    // maker();
    q=read();
    for(int i=1;i<=q;i++)   a[i]=readll();
    discrete();
    for(int o=1;o<=q;o++){
        ll x=b[a[o]];f[a[o]]^=1;
        int n=0;
        for(int i=1;i<=m;i++)
            if(f[i])    v[++n]=b[i];
        ll ans=0;
        ll s1=0,s2=0,r=0;
        for(int i=1;i<=n;i++){
            s1+=v[i];s2+=v[n-i+1];
            if(s1<s2){
                if(s1<=r){
                    if(s2-1>r)  ans+=s2-1-r,r=s2-1;
                }
                else    ans+=s2-s1,r=s2-1;
            }
        }
        print(ans);putc('\n');
    }
    flush();
}